<?php

namespace App\Http\Requests\Home;

use App\Http\Requests\Request;
use Illuminate\Foundation\Http\FormRequest;

class RegRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username' => 'required|unique:users,username|min:6',
            'password' => 'required|same:password|min:6',
            'repassword' => 'required',
            'name' => 'required',
            'mobile' => 'required|regex:/^1[34578][0-9]{9}$/|unique:users,mobile,NULL,id,deleted,0',
            'code' => 'required|unique:users,code,NULL,id,deleted,0|identitycards',
            'card_pwd' => 'required',
        ];
    }

    public function messages()
    {
        return [
            'username.required' => '用户名不能为空',
            'username.min' => '用户名不能少于6位',
            'username.unique' => '该会员账号已经被注册',
            'password.required' => '密码不能为空',
            'password.min' => '密码不能少于6位',
            'repassword.required' => '密码不能为空',
            'password.same' => '两次密码不一致',
            'name.required' => '姓名不能为空',
            'mobile.required' => '手机号不能为空',
            'mobile.unique' => '手机号已经注册',
            'mobile.regex' => '请输入有效的手机号码！',
            'code.required' => '身份证不能为空',
            'code.unique' => '该身份证已经注册',
            'card_pwd.required' => '提现密码不能为空',
        ];
    }
}
